/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beanControl;

import Utils.Helper;
import Utils.JDBCHelper;

import Utils.StringUtility;
import beanInfo.payInteres;
import java.util.ArrayList;
import javax.swing.JTable;

/**
 *
 * @author lyan
 */
public class PayInterestcontrol {

    ArrayList<String> listColumn = new ArrayList<String>();
    ArrayList<String> listValue = new ArrayList<String>();
    payInteres pit = new payInteres();

    public void listpayinteres(JTable table) {
        String sql = "select * from PayInterest";
        String[] header = {"Term", "PaymentDate", "ProfileID", "PrincipalBalance", "Money", "Status"};
        Helper.loadDataTable(sql, table, header);
    }

    public void insertPayInteres( payInteres pit) {
        Object[] values = {pit.getPaymentDate(),pit.getProfile(),pit.getBalanceInterest(),pit.getMoney(),pit.getStatus()};

        JDBCHelper.excuteInsertPlaceHolder("PayInterest", 5, values);
        Helper.successMessage("Insert  successfull", "wanning");
    }

    public void updatePayinterst(payInteres pit) {
        String[] objColumn = {"PaymentDate"," ProfileID"," BalanceInterest", "Money"," Status"};
        String[] objValues = {pit.getPaymentDate(), String.valueOf(pit.getProfile()), 
            pit.getBalanceInterest(), pit.getMoney(), pit.getStatus()};

        
        listColumn = (ArrayList<String>) StringUtility.ArrayToArrayList(objColumn);
        listValue = (ArrayList<String>) StringUtility.ArrayToArrayList(objValues);
        JDBCHelper.executeUpdate("PayInterest", listColumn, listValue, "Term", String.valueOf(pit.getTerm()));
        Helper.successMessage("Update Sucessful", "wanning");
    }

    public void Deletepayinteres(payInteres pit) {

        JDBCHelper.excuteDelete("PayInterest", "Term", String.valueOf(pit.getTerm()));
        Helper.successMessage("Delete successfull", "wanning");

    }
}
